package com.epic.base.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyInvocationHandle implements InvocationHandler {
    private Object object;

    public void setObject(Object o){
        this.object = o;
    }
    public ProxyInvocationHandle(Object o){
        this.object = 0;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//        printLog(method.getName());
        Object object = method.invoke(proxy, args);
        return object;
    }

    public Object getProxy(){
        return Proxy.newProxyInstance(object.getClass().getClassLoader(), object.getClass().getInterfaces(),this);
    }

    public void printLog(String str){
        System.out.println("exe " + str);
    }
}
